package com.cyl.game.demos.web.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.cyl.game.demos.web.entity.UserSkinrelation;

@Mapper
public interface UserSkinMapper {
    // 插入一条用户拥有皮肤记录
    @Insert("INSERT INTO user_skins (user_id, skin_id) VALUES (#{user_id}, #{skin_id})")
    int insertUserSkin(UserSkinrelation userSkin);

    // 根据用户 ID 查询该用户拥有的所有皮肤记录
    @Select("SELECT * FROM user_skins WHERE user_id = #{user_id}")
    List<UserSkinrelation> selectUserSkinsByUserId(Integer user_id);

    // 根据皮肤 ID 查询拥有该皮肤的所有用户记录（可用于统计皮肤的拥有情况等）
    @Select("SELECT * FROM user_skins WHERE skin_id = #{skin_id}")
    List<UserSkinrelation> selectUsersBySkinId(Integer skin_id);

    // 判断用户是否拥有特定皮肤（返回布尔值，方便业务逻辑判断）
    @Select("SELECT COUNT(*) > 0 FROM user_skins WHERE user_id = #{user_id} AND skin_id = #{skin_id}")
    boolean hasSkinByIds(Integer user_id, Integer skin_id);

    // 删除用户拥有的某条皮肤记录（例如因某些原因回收皮肤等情况）
    @Insert("DELETE FROM user_skins WHERE user_id = #{user_id} AND skin_id = #{skin_id}")
    int deleteUserSkinByIds(Integer user_id, Integer skin_id);
}